<?php
require_once "../connexion.php";
require_once '../Model/factureModel.php';
require_once '../Model/devisModel.php';
//Appel au singleton Connexion
$maConnexion = ConnexionSingleton::getInstance();
$maConnexion->Connect();
?>
<?php 
if(isset($_GET["suppression"]))
{
	$id_facture = $_POST["id_facture"];
	$facture = new factureModel();
	if($facture->deleteFacture($id_facture))
	{
		echo "Le facture n&deg; $id_facture &agrave; &eacute;t&eacute; supprim&eacute;";
	}
	else
	{
		echo "Erreur lors de la suppression";
	}
}
if(isset($_GET["ajouter"]))
{
	$devis = $_POST["id_devis"];
	$date = date("Y-m-d");
	
	$facture = new factureModel();
	$facture->setDevis($devis);
	$facture->setDate($date);
	if($facture->createFacture($facture))
	{
		echo "La facture &agrave; &eacute;t&eacute; g&eacute;n&eacute;rer";
	}
	else
	{
		echo "Erreur dans la g&eacute;n&eacute;ration de la facture";
	}
	
}
?>